package nc.ui.iuforeport.businessquery;


import java.awt.*;
import java.awt.event.*;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Set;

import javax.swing.*;
import javax.swing.border.EtchedBorder;
import nc.ui.ml.NCLangRes;
import nc.ui.pub.beans.*;
import nc.vo.iuforeport.businessquery.SelectFldVO;
import nc.vo.pub.querymodel.ModelUtil;
import nc.vo.pub.querymodel.RotateCrossVO;

// Referenced classes of package nc.ui.iuforeport.businessquery:
//            CrossFhSetDlg, CrossTotalDlg, RotateCrossCellRenderer

public class RotateCrossPanel extends UIPanel {
	class IvjEventHandler implements ActionListener, MouseListener {

		public void actionPerformed(ActionEvent e) {
			if (e.getSource() == getBnAddRow())
				connEtoC1(e);
			if (e.getSource() == getBnDelRow())
				connEtoC2(e);
			if (e.getSource() == getBnUpRow())
				connEtoC10(e);
			if (e.getSource() == getBnDownRow())
				connEtoC11(e);
			if (e.getSource() == getBnAddCol())
				connEtoC3(e);
			if (e.getSource() == getBnDelCol())
				connEtoC4(e);
			if (e.getSource() == getBnUpCol())
				connEtoC5(e);
			if (e.getSource() == getBnDownCol())
				connEtoC6(e);
			if (e.getSource() == getBnAddVal())
				connEtoC7(e);
			if (e.getSource() == getBnDelVal())
				connEtoC8(e);
			if (e.getSource() == getBnUpVal())
				connEtoC9(e);
			if (e.getSource() == getBnDownVal())
				connEtoC12(e);
		}

		public void mouseClicked(MouseEvent e) {
			if (e.getSource() == getLabelVal())
				connEtoC13(e);
			if (e.getSource() == getLabelRow())
				connEtoC14(e);
			if (e.getSource() == getLabelCol())
				labelCol_MouseClicked(e);
		}

		public void mouseEntered(MouseEvent mouseevent) {
		}

		public void mouseExited(MouseEvent mouseevent) {
		}

		public void mousePressed(MouseEvent mouseevent) {
		}

		public void mouseReleased(MouseEvent mouseevent) {
		}

		final RotateCrossPanel this$0;

		IvjEventHandler() {
			this$0 = RotateCrossPanel.this;
//			super();
		}
	}

	public RotateCrossPanel() {
		m_crossTotalDlg = null;
		m_crossFhDlg = null;
		m_allSfs = null;
		m_strTotalCols = null;
		m_strGroupCols = null;
		m_bRowFh = true;
		m_bColFh = false;
		m_strColComparatorClass = null;
		ivjPnCenter = null;
		ivjPnEast = null;
		ivjSclPnAll = null;
		ivjListAll = null;
		ivjListCol = null;
		ivjListRow = null;
		ivjListVal = null;
		ivjSclPnCol = null;
		ivjSclPnRow = null;
		ivjSclPnVal = null;
		ivjBnAddCol = null;
		ivjBnAddRow = null;
		ivjBnAddVal = null;
		ivjBnDelCol = null;
		ivjBnDelRow = null;
		ivjBnDelVal = null;
		ivjPnColBn = null;
		ivjPnRowBn = null;
		ivjPnValBn = null;
		ivjBnUpRow = null;
		ivjBnDownRow = null;
		ivjBnDownCol = null;
		ivjBnDownVal = null;
		ivjBnUpCol = null;
		ivjBnUpVal = null;
		ivjLabelRow = null;
		ivjLabelCol = null;
		ivjLabelVal = null;
		ivjEventHandler = new IvjEventHandler();
		initialize();
	}

	public RotateCrossPanel(boolean p0) {
		super(p0);
		m_crossTotalDlg = null;
		m_crossFhDlg = null;
		m_allSfs = null;
		m_strTotalCols = null;
		m_strGroupCols = null;
		m_bRowFh = true;
		m_bColFh = false;
		m_strColComparatorClass = null;
		ivjPnCenter = null;
		ivjPnEast = null;
		ivjSclPnAll = null;
		ivjListAll = null;
		ivjListCol = null;
		ivjListRow = null;
		ivjListVal = null;
		ivjSclPnCol = null;
		ivjSclPnRow = null;
		ivjSclPnVal = null;
		ivjBnAddCol = null;
		ivjBnAddRow = null;
		ivjBnAddVal = null;
		ivjBnDelCol = null;
		ivjBnDelRow = null;
		ivjBnDelVal = null;
		ivjPnColBn = null;
		ivjPnRowBn = null;
		ivjPnValBn = null;
		ivjBnUpRow = null;
		ivjBnDownRow = null;
		ivjBnDownCol = null;
		ivjBnDownVal = null;
		ivjBnUpCol = null;
		ivjBnUpVal = null;
		ivjLabelRow = null;
		ivjLabelCol = null;
		ivjLabelVal = null;
		ivjEventHandler = new IvjEventHandler();
	}

	public void bnAddCol_ActionPerformed(ActionEvent actionEvent) {
		Object objs[] = getListAll().getSelectedValues();
		if (objs != null) {
			int iLen = objs.length;
			int iSize = getLMCol().size();
			int iSelIndices[] = new int[iLen];
			for (int i = 0; i < objs.length; i++) {
				getLMAll().removeElement(objs[i]);
				getLMCol().addElement(objs[i]);
				iSelIndices[i] = iSize++;
			}

			getListCol().setSelectedIndices(iSelIndices);
		}
	}

	public void bnAddRow_ActionPerformed(ActionEvent actionEvent) {
		Object objs[] = getListAll().getSelectedValues();
		if (objs != null) {
			int iLen = objs.length;
			int iSize = getLMRow().size();
			int iSelIndices[] = new int[iLen];
			for (int i = 0; i < iLen; i++) {
				getLMAll().removeElement(objs[i]);
				getLMRow().addElement(objs[i]);
				iSelIndices[i] = iSize++;
			}

			getListRow().setSelectedIndices(iSelIndices);
		}
	}

	public void bnAddVal_ActionPerformed(ActionEvent actionEvent) {
		Object objs[] = getListAll().getSelectedValues();
		if (objs != null) {
			int iLen = objs.length;
			int iSize = getLMVal().size();
			int iSelIndices[] = new int[iLen];
			for (int i = 0; i < objs.length; i++)
				if (!objs[i].toString().equals("&type")) {
					getLMAll().removeElement(objs[i]);
					getLMVal().addElement(objs[i]);
					iSelIndices[i] = iSize++;
				}

			getListVal().setSelectedIndices(iSelIndices);
		}
	}

	public void bnDelCol_ActionPerformed(ActionEvent actionEvent) {
		Object objs[] = getListCol().getSelectedValues();
		if (objs != null) {
			int iLen = objs.length;
			int iSize = getLMAll().size();
			int iSelIndices[] = new int[iLen];
			for (int i = 0; i < objs.length; i++) {
				getLMCol().removeElement(objs[i]);
				getLMAll().addElement(objs[i]);
				iSelIndices[i] = iSize++;
			}

			getListAll().setSelectedIndices(iSelIndices);
		}
	}

	public void bnDelRow_ActionPerformed(ActionEvent actionEvent) {
		Object objs[] = getListRow().getSelectedValues();
		if (objs != null) {
			int iLen = objs.length;
			int iSize = getLMAll().size();
			int iSelIndices[] = new int[iLen];
			for (int i = 0; i < objs.length; i++) {
				getLMRow().removeElement(objs[i]);
				getLMAll().addElement(objs[i]);
				iSelIndices[i] = iSize++;
			}

			getListAll().setSelectedIndices(iSelIndices);
		}
	}

	public void bnDelVal_ActionPerformed(ActionEvent actionEvent) {
		Object objs[] = getListVal().getSelectedValues();
		if (objs != null) {
			int iLen = objs.length;
			int iSize = getLMAll().size();
			int iSelIndices[] = new int[iLen];
			for (int i = 0; i < objs.length; i++) {
				getLMVal().removeElement(objs[i]);
				getLMAll().addElement(objs[i]);
				iSelIndices[i] = iSize++;
			}

			getListAll().setSelectedIndices(iSelIndices);
		}
	}

	public void bnDownCol_ActionPerformed(ActionEvent actionEvent) {
		if (getListCol().getSelectedValues().length == 1) {
			int iIndex = getListCol().getSelectedIndex();
			if (iIndex < getLMCol().getSize() - 1) {
				Object obj = getListCol().getSelectedValue();
				getLMCol().removeElement(obj);
				getLMCol().insertElementAt(obj, iIndex + 1);
				getListCol().setSelectedIndex(iIndex + 1);
			}
		}
	}

	public void bnDownRow_ActionPerformed(ActionEvent actionEvent) {
		if (getListRow().getSelectedValues().length == 1) {
			int iIndex = getListRow().getSelectedIndex();
			if (iIndex < getLMRow().getSize() - 1) {
				Object obj = getListRow().getSelectedValue();
				getLMRow().removeElement(obj);
				getLMRow().insertElementAt(obj, iIndex + 1);
				getListRow().setSelectedIndex(iIndex + 1);
			}
		}
	}

	public void bnDownVal_ActionPerformed(ActionEvent actionEvent) {
		if (getListVal().getSelectedValues().length == 1) {
			int iIndex = getListVal().getSelectedIndex();
			if (iIndex < getLMVal().getSize() - 1) {
				Object obj = getListVal().getSelectedValue();
				getLMVal().removeElement(obj);
				getLMVal().insertElementAt(obj, iIndex + 1);
				getListVal().setSelectedIndex(iIndex + 1);
			}
		}
	}

	public void bnUpCol_ActionPerformed(ActionEvent actionEvent) {
		if (getListCol().getSelectedValues().length == 1) {
			int iIndex = getListCol().getSelectedIndex();
			if (iIndex > 0) {
				Object obj = getListCol().getSelectedValue();
				getLMCol().removeElement(obj);
				getLMCol().insertElementAt(obj, iIndex - 1);
				getListCol().setSelectedIndex(iIndex - 1);
			}
		}
	}

	public void bnUpRow_ActionPerformed(ActionEvent actionEvent) {
		if (getListRow().getSelectedValues().length == 1) {
			int iIndex = getListRow().getSelectedIndex();
			if (iIndex > 0) {
				Object obj = getListRow().getSelectedValue();
				getLMRow().removeElement(obj);
				getLMRow().insertElementAt(obj, iIndex - 1);
				getListRow().setSelectedIndex(iIndex - 1);
			}
		}
	}

	public void bnUpVal_ActionPerformed(ActionEvent actionEvent) {
		if (getListVal().getSelectedValues().length == 1) {
			int iIndex = getListVal().getSelectedIndex();
			if (iIndex > 0) {
				Object obj = getListVal().getSelectedValue();
				getLMVal().removeElement(obj);
				getLMVal().insertElementAt(obj, iIndex - 1);
				getListVal().setSelectedIndex(iIndex - 1);
			}
		}
	}

	public String check(boolean bDef) {
		int iRowCounts[] = { getLMRow().size(), getLMCol().size(), getLMVal().size() };
		if (iRowCounts[1] == 0)
			return NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000856");
		if (iRowCounts[2] == 0)
			return NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000857");
		if (bDef && !isWeightValid())
			return NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000858");
		int iLen = m_strTotalCols != null ? m_strTotalCols.length : 0;
		String strVals[] = getVals();
		for (int i = 0; i < iLen; i++)
			if (!ModelUtil.isElement3(m_strTotalCols[i], strVals)) {
				System.out.println((new StringBuilder()).append("\u65E0\u6548\u4EA4\u53C9\u5408\u8BA1\u5217: ").append(m_strTotalCols[i]).toString());
				return NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000859");
			}

		Hashtable hashAliasFld = getHashAliasFldvo(m_allSfs);
		iLen = m_strGroupCols != null ? m_strGroupCols.length : 0;
		for (int i = 0; i < iLen; i++)
			if (!hashAliasFld.containsKey(m_strGroupCols[i])) {
				System.out.println((new StringBuilder()).append("\u65E0\u6548\u4EA4\u53C9\u5206\u7EC4\u5217: ").append(m_strGroupCols[i]).toString());
				return NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000860");
			}

		return null;
	}

	public String checkCrossinfo() {
		int iLen = m_allSfs != null ? m_allSfs.length : 0;
		int iAllSize = getLMAll().getSize();
		if (isWeightValid())
			if (iAllSize == iLen)
				return "";
			else
				return check(false);
		if (iAllSize == iLen + 1)
			return "";
		else
			return check(false);
	}

	private void connEtoC1(ActionEvent arg1) {
		try {
			bnAddRow_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC10(ActionEvent arg1) {
		try {
			bnUpRow_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC11(ActionEvent arg1) {
		try {
			bnDownRow_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC12(ActionEvent arg1) {
		try {
			bnDownVal_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC13(MouseEvent arg1) {
		try {
			labelVal_MouseClicked(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC14(MouseEvent arg1) {
		try {
			labelRow_MouseClicked(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC2(ActionEvent arg1) {
		try {
			bnDelRow_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC3(ActionEvent arg1) {
		try {
			bnAddCol_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC4(ActionEvent arg1) {
		try {
			bnDelCol_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC5(ActionEvent arg1) {
		try {
			bnUpCol_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC6(ActionEvent arg1) {
		try {
			bnDownCol_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC7(ActionEvent arg1) {
		try {
			bnAddVal_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC8(ActionEvent arg1) {
		try {
			bnDelVal_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	private void connEtoC9(ActionEvent arg1) {
		try {
			bnUpVal_ActionPerformed(arg1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
	}

	public void defRowFh() {
		CrossFhSetDlg dlg = getCrossFhDlg();
		dlg.setRowFh(m_bRowFh);
		dlg.showModal();
		dlg.destroy();
		if (dlg.getResult() == 1)
			m_bRowFh = dlg.isRowFh();
	}

	public void defColFh() {
		CrossFhSetDlg dlg = getCrossFhDlg();
		dlg.setRowFh(m_bColFh);
		dlg.showModal();
		dlg.destroy();
		if (dlg.getResult() == 1)
			m_bColFh = dlg.isRowFh();
	}

	public void defTotal() {
		SelectFldVO sfVals[] = getSfVals();
		CrossTotalDlg dlg = getCrossTotalDlg();
		dlg.setSumCols(sfVals, m_strTotalCols);
		dlg.setGroupCols(m_allSfs, m_strGroupCols);
		dlg.showModal();
		dlg.destroy();
		if (dlg.getResult() == 1) {
			m_strTotalCols = dlg.getSumCols();
			m_strGroupCols = dlg.getGroupCols();
		}
	}

	private UIButton getBnAddCol() {
		if (ivjBnAddCol == null)
			try {
				ivjBnAddCol = new UIButton();
				ivjBnAddCol.setName("BnAddCol");
				ivjBnAddCol.setPreferredSize(new Dimension(70, 22));
				ivjBnAddCol.setText("\u2192");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnAddCol;
	}

	private UIButton getBnAddRow() {
		if (ivjBnAddRow == null)
			try {
				ivjBnAddRow = new UIButton();
				ivjBnAddRow.setName("BnAddRow");
				ivjBnAddRow.setPreferredSize(new Dimension(70, 22));
				ivjBnAddRow.setText("\u2192");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnAddRow;
	}

	private UIButton getBnAddVal() {
		if (ivjBnAddVal == null)
			try {
				ivjBnAddVal = new UIButton();
				ivjBnAddVal.setName("BnAddVal");
				ivjBnAddVal.setPreferredSize(new Dimension(70, 22));
				ivjBnAddVal.setText("\u2192");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnAddVal;
	}

	private UIButton getBnDelCol() {
		if (ivjBnDelCol == null)
			try {
				ivjBnDelCol = new UIButton();
				ivjBnDelCol.setName("BnDelCol");
				ivjBnDelCol.setText("\u2190");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnDelCol;
	}

	private UIButton getBnDelRow() {
		if (ivjBnDelRow == null)
			try {
				ivjBnDelRow = new UIButton();
				ivjBnDelRow.setName("BnDelRow");
				ivjBnDelRow.setText("\u2190");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnDelRow;
	}

	private UIButton getBnDelVal() {
		if (ivjBnDelVal == null)
			try {
				ivjBnDelVal = new UIButton();
				ivjBnDelVal.setName("BnDelVal");
				ivjBnDelVal.setText("\u2190");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnDelVal;
	}

	private UIButton getBnDownCol() {
		if (ivjBnDownCol == null)
			try {
				ivjBnDownCol = new UIButton();
				ivjBnDownCol.setName("BnDownCol");
				ivjBnDownCol.setText("\u2193");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnDownCol;
	}

	private UIButton getBnDownRow() {
		if (ivjBnDownRow == null)
			try {
				ivjBnDownRow = new UIButton();
				ivjBnDownRow.setName("BnDownRow");
				ivjBnDownRow.setText("\u2193");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnDownRow;
	}

	private UIButton getBnDownVal() {
		if (ivjBnDownVal == null)
			try {
				ivjBnDownVal = new UIButton();
				ivjBnDownVal.setName("BnDownVal");
				ivjBnDownVal.setText("\u2193");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnDownVal;
	}

	private UIButton getBnUpCol() {
		if (ivjBnUpCol == null)
			try {
				ivjBnUpCol = new UIButton();
				ivjBnUpCol.setName("BnUpCol");
				ivjBnUpCol.setPreferredSize(new Dimension(70, 22));
				ivjBnUpCol.setText("\u2191");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnUpCol;
	}

	private UIButton getBnUpRow() {
		if (ivjBnUpRow == null)
			try {
				ivjBnUpRow = new UIButton();
				ivjBnUpRow.setName("BnUpRow");
				ivjBnUpRow.setPreferredSize(new Dimension(70, 22));
				ivjBnUpRow.setText("\u2191");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnUpRow;
	}

	private UIButton getBnUpVal() {
		if (ivjBnUpVal == null)
			try {
				ivjBnUpVal = new UIButton();
				ivjBnUpVal.setName("BnUpVal");
				ivjBnUpVal.setPreferredSize(new Dimension(70, 22));
				ivjBnUpVal.setText("\u2191");
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjBnUpVal;
	}

	public CrossFhSetDlg getCrossFhDlg() {
		if (m_crossFhDlg == null)
			m_crossFhDlg = new CrossFhSetDlg(this);
		return m_crossFhDlg;
	}

	public CrossTotalDlg getCrossTotalDlg() {
		if (m_crossTotalDlg == null)
			m_crossTotalDlg = new CrossTotalDlg(this);
		return m_crossTotalDlg;
	}

	private Hashtable getHashAliasFldvo(SelectFldVO sfs[]) {
		Hashtable hashAliasFld = new Hashtable();
		int iLen = sfs != null ? sfs.length : 0;
		for (int i = 0; i < iLen; i++)
			hashAliasFld.put(sfs[i].getFldalias().toLowerCase(), sfs[i]);

		return hashAliasFld;
	}

	private UILabel getLabelCol() {
		if (ivjLabelCol == null)
			try {
				ivjLabelCol = new UILabel();
				ivjLabelCol.setName("LabelCol");
				ivjLabelCol.setText(NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000733"));
				ivjLabelCol.setToolTipText(NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000679"));
				ivjLabelCol.setForeground(Color.black);
				ivjLabelCol.setHorizontalAlignment(0);
				ivjLabelCol.setHorizontalTextPosition(0);
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjLabelCol;
	}

	private UILabel getLabelRow() {
		if (ivjLabelRow == null)
			try {
				ivjLabelRow = new UILabel();
				ivjLabelRow.setName("LabelRow");
				ivjLabelRow.setText(NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000038"));
				ivjLabelRow.setToolTipText(NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000679"));
				ivjLabelRow.setForeground(Color.black);
				ivjLabelRow.setHorizontalAlignment(0);
				ivjLabelRow.setHorizontalTextPosition(0);
				ivjLabelRow.setILabelType(0);
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjLabelRow;
	}

	private UILabel getLabelVal() {
		if (ivjLabelVal == null)
			try {
				ivjLabelVal = new UILabel();
				ivjLabelVal.setName("LabelVal");
				ivjLabelVal.setText(NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000268"));
				ivjLabelVal.setToolTipText(NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000269"));
				ivjLabelVal.setForeground(Color.black);
				ivjLabelVal.setHorizontalAlignment(0);
				ivjLabelVal.setHorizontalTextPosition(0);
				ivjLabelVal.setILabelType(0);
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjLabelVal;
	}

	private UIList getListAll() {
		if (ivjListAll == null)
			try {
				ivjListAll = new UIList();
				ivjListAll.setName("ListAll");
				ivjListAll.setBounds(0, 0, 160, 120);
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjListAll;
	}

	private UIList getListCol() {
		if (ivjListCol == null)
			try {
				ivjListCol = new UIList();
				ivjListCol.setName("ListCol");
				ivjListCol.setBounds(0, 0, 160, 120);
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjListCol;
	}

	private UIList getListRow() {
		if (ivjListRow == null)
			try {
				ivjListRow = new UIList();
				ivjListRow.setName("ListRow");
				ivjListRow.setBounds(0, 0, 160, 120);
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjListRow;
	}

	private UIList getListVal() {
		if (ivjListVal == null)
			try {
				ivjListVal = new UIList();
				ivjListVal.setName("ListVal");
				ivjListVal.setBounds(0, 0, 160, 120);
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjListVal;
	}

	private DefaultListModel getLMAll() {
		return (DefaultListModel) getListAll().getModel();
	}

	private DefaultListModel getLMCol() {
		return (DefaultListModel) getListCol().getModel();
	}

	private DefaultListModel getLMRow() {
		return (DefaultListModel) getListRow().getModel();
	}

	private DefaultListModel getLMVal() {
		return (DefaultListModel) getListVal().getModel();
	}

	private UIPanel getPnCenter() {
		if (ivjPnCenter == null)
			try {
				ivjPnCenter = new UIPanel();
				ivjPnCenter.setName("PnCenter");
				ivjPnCenter.setLayout(getPnCenterGridLayout());
				getPnCenter().add(getPnRowBn(), getPnRowBn().getName());
				getPnCenter().add(getPnColBn(), getPnColBn().getName());
				getPnCenter().add(getPnValBn(), getPnValBn().getName());
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjPnCenter;
	}

	private GridLayout getPnCenterGridLayout() {
		GridLayout ivjPnCenterGridLayout = null;
		try {
			ivjPnCenterGridLayout = new GridLayout(3, 1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
		return ivjPnCenterGridLayout;
	}

	private UIPanel getPnColBn() {
		if (ivjPnColBn == null)
			try {
				ivjPnColBn = new UIPanel();
				ivjPnColBn.setName("PnColBn");
				ivjPnColBn.setBorder(new EtchedBorder());
				ivjPnColBn.setLayout(new BoxLayout(ivjPnColBn, 1));
				ivjPnColBn.add(Box.createVerticalGlue());
				UIPanel pnNorth = new UIPanel(new FlowLayout());
				pnNorth.add(getBnAddCol());
				pnNorth.add(getBnUpCol());
				ivjPnColBn.add(pnNorth);
				UIPanel pnCenter = new UIPanel(new FlowLayout(1, 5, 0));
				pnCenter.add(getLabelCol());
				ivjPnColBn.add(pnCenter);
				UIPanel pnSouth = new UIPanel();
				pnSouth.add(getBnDelCol());
				pnSouth.add(getBnDownCol());
				ivjPnColBn.add(pnSouth);
				ivjPnColBn.add(Box.createVerticalGlue());
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjPnColBn;
	}

	private UIPanel getPnEast() {
		if (ivjPnEast == null)
			try {
				ivjPnEast = new UIPanel();
				ivjPnEast.setName("PnEast");
				ivjPnEast.setPreferredSize(new Dimension(240, 10));
				ivjPnEast.setLayout(getPnEastGridLayout());
				getPnEast().add(getSclPnRow(), getSclPnRow().getName());
				getPnEast().add(getSclPnCol(), getSclPnCol().getName());
				getPnEast().add(getSclPnVal(), getSclPnVal().getName());
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjPnEast;
	}

	private GridLayout getPnEastGridLayout() {
		GridLayout ivjPnEastGridLayout = null;
		try {
			ivjPnEastGridLayout = new GridLayout(3, 1);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
		return ivjPnEastGridLayout;
	}

	private UIPanel getPnRowBn() {
		if (ivjPnRowBn == null)
			try {
				ivjPnRowBn = new UIPanel();
				ivjPnRowBn.setName("PnRowBn");
				ivjPnRowBn.setBorder(new EtchedBorder());
				ivjPnRowBn.setLayout(new BoxLayout(ivjPnRowBn, 1));
				ivjPnRowBn.add(Box.createVerticalGlue());
				UIPanel pnNorth = new UIPanel(new FlowLayout());
				pnNorth.add(getBnAddRow());
				pnNorth.add(getBnUpRow());
				ivjPnRowBn.add(pnNorth);
				UIPanel pnCenter = new UIPanel(new FlowLayout(1, 5, 0));
				pnCenter.add(getLabelRow());
				ivjPnRowBn.add(pnCenter);
				UIPanel pnSouth = new UIPanel();
				pnSouth.add(getBnDelRow());
				pnSouth.add(getBnDownRow());
				ivjPnRowBn.add(pnSouth);
				ivjPnRowBn.add(Box.createVerticalGlue());
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjPnRowBn;
	}

	private UIPanel getPnValBn() {
		if (ivjPnValBn == null)
			try {
				ivjPnValBn = new UIPanel();
				ivjPnValBn.setName("PnValBn");
				ivjPnValBn.setBorder(new EtchedBorder());
				ivjPnValBn.setLayout(new BoxLayout(ivjPnValBn, 1));
				ivjPnValBn.add(Box.createVerticalGlue());
				UIPanel pnNorth = new UIPanel(new FlowLayout());
				pnNorth.add(getBnAddVal());
				pnNorth.add(getBnUpVal());
				ivjPnValBn.add(pnNorth);
				UIPanel pnCenter = new UIPanel(new FlowLayout(1, 5, 0));
				pnCenter.add(getLabelVal());
				ivjPnValBn.add(pnCenter);
				UIPanel pnSouth = new UIPanel();
				pnSouth.add(getBnDelVal());
				pnSouth.add(getBnDownVal());
				ivjPnValBn.add(pnSouth);
				ivjPnValBn.add(Box.createVerticalGlue());
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjPnValBn;
	}

	public RotateCrossVO getRotateCross() {
		int iSize = getLMRow().size();
		String strRows[] = new String[iSize];
		String rowsName[] = new String[iSize];
		for (int i = 0; i < iSize; i++)
			if (getLMRow().elementAt(i) instanceof SelectFldVO) {
				SelectFldVO sf = (SelectFldVO) getLMRow().elementAt(i);
				strRows[i] = sf.getFldalias();
				rowsName[i] = sf.getFldname();
			} else {
				strRows[i] = "&type";
			}

		iSize = getLMCol().size();
		String strCols[] = new String[iSize];
		String colsName[] = new String[iSize];
		for (int i = 0; i < iSize; i++)
			if (getLMCol().elementAt(i) instanceof SelectFldVO) {
				SelectFldVO sf = (SelectFldVO) getLMCol().elementAt(i);
				strCols[i] = sf.getFldalias();
				colsName[i] = sf.getFldname();
			} else {
				strCols[i] = "&type";
			}

		String strVals[] = getVals();
		String valsName[] = getvalsName();
		RotateCrossVO rc = new RotateCrossVO();
		rc.setStrRows(strRows);
		rc.setStrCols(strCols);
		rc.setStrVals(strVals);
		rc.setRowsName(rowsName);
		rc.setColsName(colsName);
		rc.setValsName(valsName);
		rc.setValTotal(m_strTotalCols);
		rc.setValGroup(m_strGroupCols);
		rc.setRowFh(m_bRowFh);
		rc.setColFh(m_bColFh);
		rc.setColComparatorClass(m_strColComparatorClass);
		return rc;
	}

	private UIScrollPane getSclPnAll() {
		if (ivjSclPnAll == null)
			try {
				ivjSclPnAll = new UIScrollPane();
				ivjSclPnAll.setName("SclPnAll");
				ivjSclPnAll.setPreferredSize(new Dimension(240, 3));
				getSclPnAll().setViewportView(getListAll());
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjSclPnAll;
	}

	private UIScrollPane getSclPnCol() {
		if (ivjSclPnCol == null)
			try {
				ivjSclPnCol = new UIScrollPane();
				ivjSclPnCol.setName("SclPnCol");
				getSclPnCol().setViewportView(getListCol());
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjSclPnCol;
	}

	private UIScrollPane getSclPnRow() {
		if (ivjSclPnRow == null)
			try {
				ivjSclPnRow = new UIScrollPane();
				ivjSclPnRow.setName("SclPnRow");
				getSclPnRow().setViewportView(getListRow());
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjSclPnRow;
	}

	private UIScrollPane getSclPnVal() {
		if (ivjSclPnVal == null)
			try {
				ivjSclPnVal = new UIScrollPane();
				ivjSclPnVal.setName("SclPnVal");
				getSclPnVal().setViewportView(getListVal());
			} catch (Throwable ivjExc) {
				handleException(ivjExc);
			}
		return ivjSclPnVal;
	}

	public SelectFldVO[] getSfVals() {
		int iSize = getLMVal().size();
		SelectFldVO sfVals[] = new SelectFldVO[iSize];
		for (int i = 0; i < iSize; i++)
			sfVals[i] = (SelectFldVO) getLMVal().elementAt(i);

		return sfVals;
	}

	public String[] getVals() {
		int iSize = getLMVal().size();
		String strVals[] = new String[iSize];
		for (int i = 0; i < iSize; i++) {
			SelectFldVO sf = (SelectFldVO) getLMVal().elementAt(i);
			strVals[i] = sf.getFldalias();
		}

		return strVals;
	}

	public String[] getvalsName() {
		int iSize = getLMVal().size();
		String valsName[] = new String[iSize];
		for (int i = 0; i < iSize; i++) {
			SelectFldVO sf = (SelectFldVO) getLMVal().elementAt(i);
			valsName[i] = sf.getFldname();
		}

		return valsName;
	}

	private void handleException(Throwable exception) {
		System.out.println("--------- \u672A\u6355\u6349\u5230\u7684\u5F02\u5E38 ---------");
		exception.printStackTrace(System.out);
	}

	private void initConnections() throws Exception {
		getBnAddRow().addActionListener(ivjEventHandler);
		getBnDelRow().addActionListener(ivjEventHandler);
		getBnUpRow().addActionListener(ivjEventHandler);
		getBnDownRow().addActionListener(ivjEventHandler);
		getBnAddCol().addActionListener(ivjEventHandler);
		getBnDelCol().addActionListener(ivjEventHandler);
		getBnUpCol().addActionListener(ivjEventHandler);
		getBnDownCol().addActionListener(ivjEventHandler);
		getBnAddVal().addActionListener(ivjEventHandler);
		getBnDelVal().addActionListener(ivjEventHandler);
		getBnUpVal().addActionListener(ivjEventHandler);
		getBnDownVal().addActionListener(ivjEventHandler);
		getLabelVal().addMouseListener(ivjEventHandler);
		getLabelRow().addMouseListener(ivjEventHandler);
		getLabelCol().addMouseListener(ivjEventHandler);
	}

	private void initialize() {
		try {
			setName("RotateCrossPanel");
			setLayout(new BorderLayout());
			setSize(600, 320);
			add(getSclPnAll(), "West");
			add(getPnEast(), "East");
			add(getPnCenter(), "Center");
			initConnections();
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
		getListAll().setModel(new DefaultListModel());
		getListRow().setModel(new DefaultListModel());
		getListCol().setModel(new DefaultListModel());
		getListVal().setModel(new DefaultListModel());
		getListAll().setCellRenderer(new RotateCrossCellRenderer());
		getListRow().setCellRenderer(new RotateCrossCellRenderer());
		getListCol().setCellRenderer(new RotateCrossCellRenderer());
		getListVal().setCellRenderer(new RotateCrossCellRenderer());
	}

	public boolean isWeightValid() {
		int iSize = getLMRow().size();
		for (int i = 0; i < iSize; i++)
			if (getLMRow().elementAt(i).toString().equals("&type"))
				return true;

		iSize = getLMCol().size();
		for (int i = 0; i < iSize; i++)
			if (getLMCol().elementAt(i).toString().equals("&type"))
				return true;

		return false;
	}

	public void labelRow_MouseClicked(MouseEvent mouseEvent) {
		if (mouseEvent.getClickCount() == 1)
			defRowFh();
	}

	public void labelCol_MouseClicked(MouseEvent mouseEvent) {
		if (mouseEvent.getClickCount() == 1)
			if (mouseEvent.isControlDown())
				defComparator();
			else
				defColFh();
	}

	public void labelVal_MouseClicked(MouseEvent mouseEvent) {
		if (mouseEvent.getClickCount() == 1)
			if (getSfVals().length == 0)
				MessageDialog.showHintDlg(this, NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000099"), NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000861"));
			else
				defTotal();
	}

	public static void main(String args[]) {
		try {
			JFrame frame = new JFrame();
			RotateCrossPanel aRotateCrossPanel = new RotateCrossPanel();
			frame.setContentPane(aRotateCrossPanel);
			frame.setSize(aRotateCrossPanel.getSize());
			frame.addWindowListener(new WindowAdapter() {

				public void windowClosing(WindowEvent e) {
					System.exit(0);
				}

			});
			frame.setVisible(true);
			Insets insets = frame.getInsets();
			frame.setSize(frame.getWidth() + insets.left + insets.right, frame.getHeight() + insets.top + insets.bottom);
			frame.setVisible(true);
		} catch (Throwable exception) {
			System.err.println("nc.ui.pub.beans.UIPanel \u7684 main() \u4E2D\u53D1\u751F\u5F02\u5E38");
			exception.printStackTrace(System.out);
		}
	}

	public void setBnEnabled(boolean bEnable) {
		getBnAddRow().setEnabled(bEnable);
		getBnDelRow().setEnabled(bEnable);
		getBnAddCol().setEnabled(bEnable);
		getBnDelCol().setEnabled(bEnable);
		getBnAddVal().setEnabled(bEnable);
		getBnDelVal().setEnabled(bEnable);
	}

	public void setRotateCross(RotateCrossVO rc, SelectFldVO sfs[]) {
		m_allSfs = sfs;
		int iLen = sfs != null ? sfs.length : 0;
		Hashtable hashAliasFld = getHashAliasFldvo(sfs);
		String strRows[] = null;
		String strCols[] = null;
		String strVals[] = null;
		if (rc == null) {
			getLMRow().removeAllElements();
			getLMCol().removeAllElements();
			getLMVal().removeAllElements();
			getLMCol().addElement("&type");
			m_strTotalCols = null;
			m_strGroupCols = null;
			m_bRowFh = true;
			m_bColFh = false;
			m_strColComparatorClass = null;
			getCrossTotalDlg().setSumCols(null, null);
			getCrossTotalDlg().setGroupCols(sfs, null);
			getCrossFhDlg().setRowFh(true);
		} else {
			strRows = rc.getStrRows();
			strCols = rc.getStrCols();
			strVals = rc.getStrVals();
			m_strTotalCols = rc.getValTotals();
			m_strGroupCols = rc.getValGroups();
			m_bRowFh = rc.isRowFh();
			m_bColFh = rc.isColFh();
			m_strColComparatorClass = rc.getColComparatorClass();
			iLen = strRows != null ? strRows.length : 0;
			for (int i = 0; i < iLen; i++) {
				if (strRows[i].equals("&type")) {
					getLMRow().addElement(strRows[i]);
					continue;
				}
				strRows[i] = strRows[i].toLowerCase();
				if (hashAliasFld.containsKey(strRows[i])) {
					getLMRow().addElement(hashAliasFld.get(strRows[i]));
					hashAliasFld.remove(strRows[i]);
				}
			}

			iLen = strCols != null ? strCols.length : 0;
			for (int i = 0; i < iLen; i++) {
				if (strCols[i].equals("&type")) {
					getLMCol().addElement(strCols[i]);
					continue;
				}
				strCols[i] = strCols[i].toLowerCase();
				if (hashAliasFld.containsKey(strCols[i])) {
					getLMCol().addElement(hashAliasFld.get(strCols[i].toLowerCase()));
					hashAliasFld.remove(strCols[i]);
				}
			}

			iLen = strVals != null ? strVals.length : 0;
			for (int i = 0; i < iLen; i++) {
				strVals[i] = strVals[i].toLowerCase();
				if (hashAliasFld.containsKey(strVals[i])) {
					getLMVal().addElement(hashAliasFld.get(strVals[i].toLowerCase()));
					hashAliasFld.remove(strVals[i]);
				}
			}

		}
		getLMAll().removeAllElements();
//		String key;
//		for (Enumeration nodes = hashAliasFld.keys(); nodes.hasMoreElements(); getLMAll().addElement(hashAliasFld.get(key)))
//			key = nodes.nextElement().toString();
//		Object[] keys = hashAliasFld.keySet().toArray();
		Object[] values = hashAliasFld.values().toArray();
//		Object[] entrys = hashAliasFld.entrySet().toArray();
//		Set set = hashAliasFld.entrySet();
		Arrays.sort(values);
		for (int i = 0; i < values.length; i++) {
			getLMAll().addElement(values[i]);
		}
	}

	public void defComparator() {
		Object objClassName = MessageDialog.showInputDlg(this, NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000099"), NCLangRes.getInstance().getStrByID("10241201",
				"UPP10241201-001340"), m_strColComparatorClass, 100);
		if (objClassName != null && !objClassName.toString().trim().equals(""))
			try {
				Class.forName(objClassName.toString());
				m_strColComparatorClass = objClassName.toString();
			} catch (Exception e) {
				e.printStackTrace();
				MessageDialog.showWarningDlg(this, NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-000099"), NCLangRes.getInstance().getStrByID("10241201", "UPP10241201-001341"));
			}
		else
			m_strColComparatorClass = null;
	}

	private CrossTotalDlg m_crossTotalDlg;

	private CrossFhSetDlg m_crossFhDlg;

	private SelectFldVO m_allSfs[];

	private String m_strTotalCols[];

	private String m_strGroupCols[];

	private boolean m_bRowFh;

	private boolean m_bColFh;

	private String m_strColComparatorClass;

	private UIPanel ivjPnCenter;

	private UIPanel ivjPnEast;

	private UIScrollPane ivjSclPnAll;

	private UIList ivjListAll;

	private UIList ivjListCol;

	private UIList ivjListRow;

	private UIList ivjListVal;

	private UIScrollPane ivjSclPnCol;

	private UIScrollPane ivjSclPnRow;

	private UIScrollPane ivjSclPnVal;

	private UIButton ivjBnAddCol;

	private UIButton ivjBnAddRow;

	private UIButton ivjBnAddVal;

	private UIButton ivjBnDelCol;

	private UIButton ivjBnDelRow;

	private UIButton ivjBnDelVal;

	private UIPanel ivjPnColBn;

	private UIPanel ivjPnRowBn;

	private UIPanel ivjPnValBn;

	private UIButton ivjBnUpRow;

	private UIButton ivjBnDownRow;

	private UIButton ivjBnDownCol;

	private UIButton ivjBnDownVal;

	private UIButton ivjBnUpCol;

	private UIButton ivjBnUpVal;

	private UILabel ivjLabelRow;

	private UILabel ivjLabelCol;

	private UILabel ivjLabelVal;

	IvjEventHandler ivjEventHandler;

}
